package 双指针.快乐数;

import java.util.Scanner;

/**
 * Created with IntelliJ IDEA.
 * Description:
 * User: 25228
 * Date: 2025-03-03
 * Time: 18:25
 */
public class ex {
    public static void main(String[] args) {
        Scanner scanner=new Scanner(System.in);
        int a=scanner.nextInt();
        int show=a;
        int fast=sum(a);
        while (show!=fast){
            show=sum(show);
            fast=sum(sum(fast));
        }
        if(show==1){
            System.out.println("是快乐数");
        }else {
            System.out.println("不是快乐数");
        }
    }
    public static int sum(int n){
        int s=0;
        while (n!=0){
            s+=Math.pow(n%10,2);
            n/=10;
        }
        return s;
    }
}